package com.james.happyfarm.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.james.happyfarm.JDO.User;
import com.james.happyfarm.modules.LoginModule;

public class AddUser extends HttpServlet {
	
	private static final long serialVersionUID = -3079878671501760024L;

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String username = req.getParameter("username");
		String password = req.getParameter("password");		
		String cookies = req.getParameter("cookies");	
		String uid = req.getParameter("uid");	
		String verifyCode = req.getParameter("verifyCode");	
		
		// TODO new LoginModule().getUser(username, password);
		User user = new User(uid, username, password, verifyCode, cookies);
		new LoginModule().saveUser(user);
		
		// TODO get friend list;
		
		resp.getWriter().write("succeed to add user!");
		
	}

}
